package com.flame.auth.core.exception;

import java.text.MessageFormat;

import com.flame.core.exception.ExceptionLevel;
import com.flame.core.exception.ExceptionMessage;

/**
 * flame_user_account 用户账号表
 *
 * @author 吴欣童
 * @since 2022-12-14 16:06:58
 */
public enum AuthExceptionMessage implements ExceptionMessage {
    ACCOUNT_NOT_EXIST("100001", "登录失败，账号或密码错误", ExceptionLevel.INFO),
    ACCOUNT_STATUS_ERROR_CANCEL("120001", "登录失败，账号[{0}]已注销", ExceptionLevel.INFO),
    ACCOUNT_STATUS_ERROR_FREEZE("120001", "登录失败，账号[{0}]已冻结", ExceptionLevel.INFO),
    ACCOUNT_STATUS_ERROR_LOCK("120001", "多次登录失败，账号[{0}]已锁定，请{1}后重新登录", ExceptionLevel.INFO),
    ACCOUNT_LOGIN_TIMEOUT("120001", "登录有效期超时，请重新登录", ExceptionLevel.INFO),
    TOKEN_INVALIDE("120001", "请求失败，认证校验异常", ExceptionLevel.INFO),
    ACCOUNT_NO_AUTH("120001", "无权限", ExceptionLevel.INFO);

    private String code;

    private String message;

    private ExceptionLevel level;

    AuthExceptionMessage(String code, String message, ExceptionLevel level) {
        this.code = code;
        this.message = message;
        this.level = level;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getMessage(Object... args) {
        return MessageFormat.format(this.message, args);
    }

    @Override
    public ExceptionLevel getLevel() {
        return level;
    }
}
